<?php
namespace App\Api\Models;

use Illuminate\Database\Eloquent\Model;

class CmcEmailSubscribel extends Model
{
    protected $table = 'cmc_email_subscribel';

    /**
     * 查询用户绑定的邮箱个数
     * @param $uid 用户id
     * @return int
     */
    public static function countSubEmail($uid)
    {
        return count(self::where('uid',$uid)->get()->toArray());
    }

    /**
     * 获取用户邮箱数据
     * @param $uid 用户id
     * @param $email 用户邮箱
     * @return mixed
     */
    public static function dataSubEmail($uid,$email)
    {
        return self::where('uid',$uid)->where('email',$email)->get()->toArray();
    }

    /**
     * 将邮箱信息进行添加
     * @param $params
     * @return mixed
     */
    public static function addSubEmail($params)
    {
        return self::insert($params);
    }

    /**
     * 改变认证状态
     * @param $uid 用户id
     * @param $email 用户邮箱
     * @return mixed
     */
    public static function saveSubEmail($uid,$email)
    {
        return self::where('uid',$uid)->where('email',$email)->update(['subscribe_status'=>1]);
    }
}